const int analogOutPin=3;
int ledLight=0;
 int i = 1;
void setup() {
 Serial.begin(9600);

}

void loop() {
  if(i<256)
  {
    i++;
    ledLight++;
    ledLight=ledLight%256;
    Serial.println(ledLight);
    analogWrite(analogOutPin,ledLight);
    
  }
  if(i>=256 && i <= 510)
  {
    i++;
    ledLight--;
    ledLight%=256;
     Serial.println(ledLight);
    analogWrite(analogOutPin,ledLight);
  }
  if(i==511)
    i = 1;
  
}
